<!DOCTYPE html>
<html>
<head>
<div th:include="base-libs :: base-libs" />
<title>基层-综合信息月报</title>

<meta name="content-type" content="text/html; charset=UTF-8">

	<style>
		body {
			background: #fff;
			overflow:hidden;
			text-align: center;
		}
		.laydate-icon{
		    line-height: 28px;
		    background-color: #fff;
		    height: 28px;
		    border: 1px solid #B6B6B6;
		    border-radius: 5px;
		    width:84% !important;
		}
		.titleTd{
			width:21%;
		}
	</style>

	<script>
		$(function(){
            $(this).registerManagerPage({cacheTables:["TB_ZY_BBZT"],callback:initData});
			initView();
		})
		
		function initView(){
			$("body").on('click', '#btnTj', function(){
				if($(".form-control").QuickValidate()){
					$.QuickRemote.AjaxFiledFormSubmit("myForm", function(result){ 
						if(result.state){
							$.QuickAlert.alertNormal("月报保存成功！", {callback: function(){
								//$("#south").hide();
								//$("#ZTMC").val("待审核");
                                queryDataByNowDate();
							}});
						}else{
							var info = result["info"];
							$.QuickAlert.alertFail({content: info["faultInfo"]});
						}
					}, {type: $("#myForm").data("type")})
				}
			})
			
			//审核记录
			$("body").on('click','#btnShjl',function(){
				StoreCache.setCache("BBID", $("#ID").val());
				parent.layer.open({
					  type: 2,
					  area: ["60%", "500px"],
					  content: contextRoot + 'wsj/bbShjl.html',
					  scrollbar: false,
					  resize: false,
					  title:'审核记录'
				});
			});
		}
		
		function initData(){
			var date = new Date(),
				NF = date.getFullYear(),
				YF = date.getMonth() + 1;
			if(YF<10) YF = '0' + YF;
			queryDataByNowDate({NF: NF,YF: YF});
		}
		
		/** 通过当前时间查询数据  */
		function queryDataByNowDate(dateObj){
		    var config = $.extend({},dateObj);
			if(StringUtils.isEmpty(config.NF)){
                config = getYearAndMonth();
			}
			var queryParams = {
				NF: config.NF,
				YF: config.YF
			}
			var backParams = {
				NFYF: config.NF + '-' + config.YF,
				NF: config.NF
			}
			$.QuickRemote.AjaxJson(contextRoot + "jcyb/queryOne", queryDataByNowDateBack, queryParams, backParams);
		}
		/** 通过当前时间查询数据--回调  */
		function queryDataByNowDateBack(result, backParams){
			if(!StringUtils.isEmpty(result.state)){
				result = $.extend(result,backParams);
				if(result.ZT == 1 || result.ZT == 3){
					//待审核||审核通过
					btnController('remove');
					$("input:not('#NFYF')").attr("disabled",'disabled');
				}else if(result.ZT == 2){
					//审核不同过
					$("#myForm").data("type","update");
					btnController('add');
                    $("input:not('#NFYF')").removeAttr("disabled");
				}else{
					$("#myForm").data("type","add");
                    $("input:not('#NFYF')").removeAttr("disabled");
					btnController('add');
				}
				
				result.ZTMC = '未填报';
                var bbztArr = StoreCache.getCache("TB_ZY_BBZT");
                if(!$.isEmptyObject(bbztArr) && !$.isEmptyObject(bbztArr = bbztArr.data)){
                    $.each(bbztArr, function(i,item){
                        if(item.XMDM == result.ZT){
                            result.ZTMC = item.XMMC;
                            return false;
                        }
                    })
                }

				$(".form-control").each(function(){
					var name = $(this).attr('name');
					$(this).val(result[name]).html(result[name]);
				})
				var oldNf = parseInt(result.NF) - 1 ;
				var queryParams = {NF: oldNf}
				$.QuickRemote.AjaxJson(contextRoot + "jcnb/queryNbInfo", function(re){
					//设置keyup事件，计算百分比
					var keyupParamArr = [
		                     ['QYZRS','x','QYL','',re.XQHJRKS],//签约率
		                     ['QYZDRQZS','x','ZDRQQYFGL','',re.ZDRQS],//重点人群签约覆盖率
		                     ['SZLYRC','SZRC','SZLYL'],//上转履约率
		                     ['ZRLYRC','ZRRC','ZRLYL'],//转入履约率
					];
					setKeyupFun(keyupParamArr);
				}, queryParams);
			}else{
				$.QuickAlert.alertFail({content: result.info});
			}
		}
		
		/** 按钮控制  */
		function btnController(type){
			if(type == 'add'){
				var btns = $("#btnBox").html();
				$("#south").empty().append($(btns)).show();
			}else{
				$("#south").hide().empty();
			}
			$('body').layout("resize")
		}
		
		/**  获取选择的年份和月份  */
		function getYearAndMonth() {
		    var NF = $dp.cal.newdate.y,
		    	YF = $dp.cal.newdate.M;
			if(YF<10) YF = '0' + YF;
			return {NF: NF,YF: YF};
		}
		
		/** 设置keyup事件  */
		function setKeyupFun(keyupParamArr){
			$.each(keyupParamArr, function(i,item){
				$('#'+item[0]).add('#'+item[1]).keyup(function(){
					percent(item[0], item[1], item[2], item[3], item[4]);
				})
				$('#'+item[0]).trigger('keyup');
			})
		}
		
		/** 
		 *	计算百分百： csId:除数id | bcsId:被除数id | replyId:展示结果的标签id | cs:除数 | bcs:被除数 
		 *		注：当csId与cs（bcsId与bcs）同时存在时，以cs(bcs)为主--也就是直接指定静态的除数（被除数）
		 */
		function percent(csId,bcsId,replyId,cs,bcs){
			var num1 = parseFloat(cs || $("#"+csId).val());
			var num2 = parseFloat(bcs || $("#"+bcsId).val());
			var result;
			if(num1 && num2){
				result = (num1/num2*100).toFixed(2) + "%";
			}
			$("#"+replyId).val(result).html(result);
		}
	</script>
</head>

<body class="easyui-layout">
<form id="myForm" action="save">
	<div region="north" style="height:60px;border:0;border-bottom:1px solid #ddd">
		<table class="form-table" style="margin-top:10px;">
			<tr>
				<td class="td-text">审核状态：</td>
				<td class="td-content">
					<input id="ZTMC" name="ZTMC" class="form-control" readonly="readonly"/>
				</td>
				<td class="td-text">机构名称：</td>
				<td class="td-content">
					<input name="JGMC" class="form-control" readonly="readonly"/>
				</td>
				<td class="td-text"><label>月份：</label></td>
				<td class="td-content">
					<input id="NFYF" class="form-control laydate-icon" name="NFYF" onclick="WdatePicker({dateFmt:'yyyy-MM',onpicking:queryDataByNowDate})" 
						quick-config="label:'月份', validateProxy:'notNull'"/>
				</td>
				<td>
					<button id="btnShjl" class="btn btn-info" type="button">审核记录</button>
				</td>
			</tr>
		</table>
	</div>
	<div region="center" border="false" style="overflow-x: hidden">
		<div class="easyui-panel" title="一、家庭医生签约情况" border="false" style="width:100%">
			<table class="form-table">
				<tr>
					<td class="td-text titleTd">
						<label>1.家庭医生团队数：</label>
					</td>
					<td class="td-content">
						<input id="ID" name="ID" class="form-control" type="hidden"/>
						<input name="JTYSTDS" class="form-control dataFiled" 
						 quick-config="label:'家庭医生团队数', validateProxy:'notNull length num', length: '10'" />
					</td>
					<td class="td-text titleTd"><label>2.团队家庭医生数：</label></td>
					<td class="td-content">
						<input name="TDJTYSS" class="form-control dataField" 
						quick-config="label:'团队家庭医生数', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>3.团队护士数：</label></td>
					<td class="td-content">
						<input name="TDHSS" class="form-control" 
						quick-config="label:'团队护士数', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>4.团队多点执业医师数：</label></td>
					<td class="td-content">
						<input name="TDDDZYYSS" class="form-control" 
						quick-config="label:'团队多点执业医师数', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>5.签约总人数</label>/本期新增签约人数：</td>
					<td class="td-content">
						<input id="QYZRS" name="QYZRS" class="form-control" style="width:40%;"
						quick-config="label:'签约总人数', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input name="BQXZQYRS" class="form-control" style="width:40%;"
						quick-config="label:'本期新增签约人数', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>6.签约率：</label></td>
					<td class="td-content">
						<input id="QYL" class="form-control" placeholder="签约总人数/辖区内户籍人口数" readonly="readonly"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>7.签约重点人群总数</label>/本期新增签约数：</td>
					<td class="td-content">
						<input  id="QYZDRQZS" name="QYZDRQZS" class="form-control" style="width:40%;" 
						quick-config="label:'签约重点人群总数', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input name="BQXZZDRQQYS" class="form-control" style="width:40%;" 
						quick-config="label:'本期新增签约数', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>8.重点人群签约覆盖率：</label></td>
					<td class="td-content">
						<input id="ZDRQQYFGL" class="form-control" placeholder="签约重点人群总数/辖区内重点人群数" readonly="readonly"/>
					</td>
				</tr>
			</table>
		</div>
		<div class="easyui-panel" title="二、慢病规范化管理情况" border="false" style="width:100%">
			<table class="form-table">
				<tr>
					<td class="td-text titleTd"><label>1.高血压患者规范管理数：</label></td>
					<td class="td-content">
						<input name="GXYHZGFGLS" class="form-control" type="text"
						quick-config="label:'高血压患者规范管理数', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text titleTd"><label>2.糖尿病患者规范管理数：</label></td>
					<td class="td-content">
						<input name="TNBHZGFGLS" class="form-control" 
						quick-config="label:'糖尿病患者规范管理数', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>3.高血压签约患者规范管理数：</label></td>
					<td class="td-content">
						<input name="GXYQYHZGFGLS" class="form-control" 
						quick-config="label:'高血压签约患者规范管理数', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>4.糖尿病签约患者规范管理数：</label></td>
					<td class="td-content">
						<input name="TNBQYHZGFGLS" class="form-control" 
						quick-config="label:'糖尿病签约患者规范管理数', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
			</table>
	
		</div>
	
		<div class="easyui-panel" title="三、就诊及转诊情况" border="false" style="width:100%">
			<table class="form-table">
				<tr>
					<td class="td-text titleTd"><label>1.就诊人次：</label></td>
					<td class="td-content">
						<input name="JZRC" class="form-control" 
						quick-config="label:'就诊人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text titleTd"><label>2.签约就诊人次：</label></td>
					<td class="td-content">
						<input name="QYJZRC" class="form-control" 
						quick-config="label:'签约就诊人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>3.上转人次</label>/上转履约人次：</td>
					<td class="td-content">
						<input id="SZRC" name="SZRC" class="form-control" style="width:40%;" 
						quick-config="label:'上转人次', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input id="SZLYRC" name="SZLYRC" class="form-control" style="width:40%;" 
						quick-config="label:'上转履约人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>4.上转履约率：</label></td>
					<td class="td-content">
						<input id="SZLYL" class="form-control" placeholder="上转履约人次/上转人次" readonly="readonly"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>5.门诊上转人次</label>/门诊上转履约人次：</td>
					<td class="td-content">
						<input name="MZSZRC" class="form-control" style="width:40%;" 
						quick-config="label:'门诊上转人次', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input name="MZSZLYRC" class="form-control" style="width:40%;" 
						quick-config="label:'门诊上转履约人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>6.住院上转人次</label>/住院上转履约人次：</td>
					<td class="td-content">
						<input name="ZYSZRC" class="form-control" style="width:40%;" 
						quick-config="label:'住院上转人次', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input name="ZYSZLYRC" class="form-control" style="width:40%;" 
						quick-config="label:'住院上转履约人次', validateProxy:'notNull length num', length: '10'"/>
				</tr>
				<tr>
					<td class="td-text"><label>7.转入人次</label>/转入履约人次：</td>
					<td class="td-content">
						<input id="ZRRC" name="ZRRC" class="form-control" style="width:40%;" 
						quick-config="label:'转入人次', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input id="ZRLYRC" name="ZRLYRC" class="form-control" style="width:40%;" 
						quick-config="label:'转入履约人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>8.转入履约率：</label></td>
					<td class="td-content">
						<input id="ZRLYL" class="form-control" placeholder="转入履约人次/转入人次" readonly="readonly"/>
					</td>
				</tr>
			</table>
		</div>
	</div>
	<div region="south" id="south" style="height:45px;line-height:40px;text-align:center;border:0;border-top:1px solid #ddd">
	</div>
</form>

</body>
<script type="text/html" id="btnBox">
	<button id="btnTj" class="btn btn-info" type="button">提交</button>
</script>
</html>
